//
//  AppDelegate.m
//  UI1_UIView
//
//  Created by dllo on 15/9/14.
//  Copyright (c) 2015年 Dior_3g. All rights reserved.
//

#import "AppDelegate.h"


//      延展, 主要写的地方
@interface AppDelegate ()

@end

@implementation AppDelegate

- (void)dealloc {
    [_window release];
    [super dealloc];
}


//- (void)setName:(NSString *)name {
//    if (_name != name) {
//        [_name release];
//        _name = [name copy];
//    }
//    [name retain];
//    [_name release];
//    _name = name;
//}



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    //      创建一个窗口, 让它的尺寸和屏幕尺寸等大
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    // Override point for customization after application launch.
    
    //      修改窗口的背景颜色
    self.window.backgroundColor = [UIColor blueColor];
    
    //      让当前窗口可见, 并且成为主窗口
    [self.window makeKeyAndVisible];
    
    //      释放
    [_window release];
    
    
    //      UI  View
    //      第一步 : 创建
    //      先看继承关系, 在找这个类有没有自己的初始化方法
    //UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
   
    //      第二步 : 设置背景颜色
    //view.backgroundColor = [UIColor greenColor];
    
    //      第三步 : 把视图在window上显示出来
    //[self.window addSubview:view];
    
    //  父视图通过一个数组来管理身上的子视图
    
    
    //      第四步 : 释放
    //[view release];
    
    
    //NSLog(@"%ld", view.retainCount);
    //      因为父视图把子视图放到 数组 来进行管理, 数组会对 对象的引用计数 +1 , 所以我们可以在添加属性之后把对
    //      象释放掉, 抵消 alloc 所产生的 +1
    
    
    //      创建两个view
    //UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(25, 25, 150, 150)];
    //topView.backgroundColor = [UIColor redColor];
    ///[view addSubview:topView];
    //[topView release];
    
    
    //UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(25, 25, 100, 100)];
    //leftView.backgroundColor = [UIColor blackColor];
    //[topView addSubview:leftView];
    //[leftView release];
    
    //  1. 一个视图有一个父视图, 但是可以有多个子视图
    //  2. 子视图的坐标起点是相对父视图的0,0位置

    
    
    //      通过父视图来管理子视图
    //      父视图可以管理层级关系
    //    [self.window bringSubviewToFront:view];
    //[self.window sendSubviewToBack:view];
    
    
    //      透明度, 范围从0到1, 默认是1
    //leftView.alpha = 0.7;
    
    //      隐藏, 默认NO(不隐藏)
    //topView.hidden = YES;
    
    //      打印当前对象的父视图
    //NSLog(@"%@", view.superview);
    
    //      打印当前对象的子视图
    //NSLog(@"%@", view.subviews);
    
    //      视图的tag值, 默认都是0
    //view.tag = 1000;
    //UIView *tempView = [self.window viewWithTag:1000];
    //      地址是一样的
    //NSLog(@"%@, %@", view, tempView);
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
